<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>修改角色</title>
$!{include("import_js_css.html")}
<link rel="stylesheet" type="text/css"
	href="/yueyoga_all2014/app/admin/resources/css/basic.css" />
</head>
<body>
	<!-- #set(Role role) -->
	$!{include("header.html")}
	<div class="menu_all">
		<div class="div_search_result clear">
			<div class="panel-heading panel-result-title">
				<h3 class="panel-title">修改角色</h3>
			</div>
			<div class="panel-form-add">
				<form class="form-horizontal" action="yueyogaAdmin/updateRoleUser.jhtml" method="POST">
					<div class="panel-form-layout">
						<label for="txtUserName" class="col-sm-1 control-label">名称</label>
						<div class="col-sm-3">
							<input type="text" required class="form-control panel-text-bg" name="userName"
								id="txtUserName" value="${role.name}" >
							<input type="hidden" value="${role.id}" name="roleId" id="roleId"/> 
						</div>
						<label for="enabled" class="col-sm-1 control-label">是否启用</label>
						<div class="col-sm-3">
						<select class="selectpicker show-menu-arrow" data-width="100%"
								name="enabled" id="enabled">
								<option value="1">启用</option>
								<option value="0">禁用</option>
							</select>
						</div>
						<br /> <br />
						 <label for="txtUserdescription"
							class="col-sm-1 control-label">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述</label>
						<div class="col-sm-3">
							<textarea class="form-control panel-form-address" name="description" id="description" >${role.description}</textarea>
						</div>
						<br /> <br /><br /> <br />
						<div class="panel-btn-search">
							<button id="btnSave" type="button" class="btn btn-default btn-ade-default panel-mr">保存</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		$("#enabled").select2({
			width: "100%",
			minimumResultsForSearch: -1
		});
		
		$("#enabled").select2('val', '${role.enabled=='true'?'1':'0'}');
		//--点击保存
		$("#btnSave").click(function(){
			var roleId = $("#roleId").val();
			var name = $("#txtUserName").val();
			var enabled = $("#enabled").val();
			var description = $("#description").val();
			var userInherit = '';
			var url = "yueyogaAdmin/updateRoleUser.jhtml";
			$.post(url, {
				roleId:roleId,
				userName : name,
				userInherit:userInherit,
				enabled : enabled,
				description : description
			}, function(resp) {
				var data = eval('(' + resp + ')');
				if(data.success){
					var d = alert(data.msg);
					setTimeout(function(){
						d.close().remove();
						window.location.href = "yueyogaAdmin/findRoleUsers.jhtml";
					},1000);
				}else{
					error(resp.msg);
				}
			});
		});
	});
</script>
</html>
